﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using CourseSystem.Core.BLL;

namespace CourseSystem.Common.Helpers
{
    public class StudentHelper
    {
        public static List<SelectListItem> GetCollege(bool needDef = true)
        {
            var colList = CollegeBLL.GetAll();
            var re = colList.Select(item => new SelectListItem { Value = item.Id.ToString(), Text = item.Name }).ToList();
            if (needDef)
                re.Insert(0, new SelectListItem { Text = "请选择", Value = "0" });
            return re;
        }

        public static List<SelectListItem> GetSubject(int cid, bool needDef = true)
        {
            var subList = SubjectBLL.GetByColId(cid);
            var re = subList.Select(item => new SelectListItem { Value = item.Id.ToString(), Text = item.Name }).ToList();
            if (needDef)
                re.Insert(0, new SelectListItem { Text = "请选择", Value = "0" });
            return re;
        }

        public static List<SelectListItem> GetClass(bool needDef = true)
        {
            var colList = ClassBLL.GetAll();
            var re = colList.Select(item => new SelectListItem { Value = item.Id.ToString(), Text = item.Class.ToString() }).ToList();
            if (needDef)
                re.Insert(0, new SelectListItem { Text = "请选择", Value = "0" });
            return re;
        }

        public static List<SelectListItem> GetGradeYear(bool needDef = true)
        {
            var colList = GradeYearBLL.GetAll();
            var re = colList.Select(item => new SelectListItem { Value = item.Id.ToString(), Text = item.Year.ToString() }).ToList();
            if (needDef)
                re.Insert(0,new SelectListItem { Text = "请选择", Value = "0" });
            return re;
        }
    }
}